      IMPLICIT REAL*8 (A-H, L-Z)
      real*8 porb(10000),mdot(10000),dt(10000)
      real*8 p(100),md(100),a(100),b(100)
      real*8 porb1,md1,dt1,m
      integer i,j,k
      real*8 t,ran0,ran

            
      OPEN(14,file='lp.dat',status='unknown')
      open(100,file='lps.dat',status='unknown')
      p(0) = 0.0315
      md(0) = -12
      
      do i = 1, 45
      p(i) = 10**(log10(P(i-1))+ 0.1)
      enddo
      
      do j = 1, 64
      md(j) = md(j-1) + 0.125
      enddo
      
      do k = 1,10000
      
      read(14,*) porb1,md1,dt1,m
c      mcr = 3.2d-9*porb1**1.4
c      if(m.ge.0.3.and.m.le.1.5.and.
c     & md1.ge.mcr)then
c      call random_number(t)
c      ran0 = 1.4771*t
c      ran = 10**ran0
c      write(1,*)ran,t
c       md1 = ran*md1
c       dt1 = dt1/ran
c      endif       
      md1 = log10(md1)
      
      if(md1.gt.-12.and.md1.lt.-4)then
      
      do i = 1,45
      if(porb1.ge.p(i-1).and.porb1.lt.p(i))then
      a(i) = i
      WRITE(100,112,advance='no')p(i)
      endif
      enddo

      do j = 1, 64
      if(md1.ge.md(j-1).and.md1.lt.md(j))then
      b(j) = j
      WRITE(100,112)md(j),dt1
      endif
      enddo
      
      endif
112   format(1f8.3,1E12.2)      
      enddo
      
      end
